package com.ajavaer.framework.core.orm.service;


import com.ajavaer.framework.core.orm.dao.BaseDAO;
import com.ajavaer.framework.core.orm.po.LogicDeletePo;
import com.ajavaer.framework.core.request.PagingRequest;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;

import javax.persistence.EntityManager;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public interface LogicDeleteService<T extends LogicDeletePo, ID extends Serializable> extends BaseService<T, ID> {

    T getEntity();

    BaseDAO getBaseDAO();

    T saveOrUpdate(T entity);

    void delete(T entity);

    void delete(ID id);

    void delete(Iterable<T> entites);

    void deleteByIdIn(Collection<ID> idList);

    T getById(ID id);

    boolean exists(Example<T> entity);

    Page<T> findPaging(Integer page, Integer rows, Map<String, Object> searchMap, Sort sort);

    Page<T> findPaging(Integer page, Integer rows, Specification specification, Sort sort);

    Page<T> findPaging(PagingRequest pagingRequest);

    List<T> findAll(Specification<T> spec, Sort sort);

    List<T> findAll();

    List<T> findAll(Map<String, Object> searchParams);

    List<T> findAll(Map<String, Object> searchParams, Sort sort);

    List<T> findByProperty(String property, Object value);

    List<T> findByProperty(String property, Object value, Sort sort);

    EntityManager getEntityManager();

}